-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get event context on EventSubscription #423
Conversation
I'm happy with the general idea (though I think If you're keen on exposing these details sooner then I'd be happy for this to progress and get merged in the meantime. |
c3d85fb
to
8ff7f2f
Compare
src/subscription.rs
Outdated
pub struct EventContext<T> { | ||
pub block: T, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
pub struct EventContext<T> { | |
pub block: T, | |
pub struct EventContext<Hash> { | |
pub block_hash: Hash, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, done! Also rebased to master.
8ff7f2f
to
a615b79
Compare
Had to rebase twice, missed your second push to master :) |
Awesome; CI runs approved so we can see how it goes. Given this PR and comments on #413 I'll start work on simplfying this |
@jsdw I would appreciate it if you could get this merged. I'm okay if you'll eventually replace it :) |
@lamafab if you could resolve the small cargo fmt errors (run |
@jsdw done, please run the workflows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* implement next_context * write test_context for method next_context * change how events are uniquely identified * undo local changes for test-runtime * introduce EventContext struct * adjust test_context to EventContext struct * fix return type for next_context * add suggestions by jsdw * ran cargo fmt and clippy
Currently, the
next
method on theEventSubscription
type only returns the event itself, not clarifying where it occurred. This PR introduces a new method,next_context
, that additionally returns the corresponding block hash and the index of the event.Btw, I think it would be great to have a block number, too, but I think that'd require upstream substrate changes (or additional queries on
subxt
's side).Feedback/criticism appreciated.
EDIT: Will wait for your feedback before I'll resolve the conflicts.